#include<iostream>
#include<string>
#include<vector>
#include<deque>
#include<algorithm>
using namespace std;

//有5名选手，选手ABCDE，10个评委分别对每一名选手打分，去除最高分，去除最低分，取平均分

class Person
{
public:
    Person(string name, int score)
    {
        this->m_name = name;
        this->m_score = score;
    }

    string m_name;
    int m_score;
};
//创建
void creatperson(vector<Person>& v)
{
    string nameseed = "ABCDE";
    for (int i = 0;i < 5;i++)
    {
        string name = "选手";
        name += nameseed[i];

        int score = 0;

        Person p(name, score);

        //将创建的person对象，放入到容器中
        v.push_back(p);
    }
}

//打分
void setscore(vector<Person>& v)
{
    srand(time(nullptr));
    for (auto& it : v)
    {
        //将评委的分数 放入到deque容器中
        deque<int> d;
        for (int i = 0;i < 10;i++)
        {
            int score = rand() % 41 + 60;
            d.push_back(score);
        }

        cout << "选手：" << it.m_name << " 打分：" << endl;
        for (auto it1 : d)
        {
            cout << it1 << " ";
        }
        cout << endl;

        //排序
        sort(d.begin(), d.end());

        //去除
        d.pop_back();
        d.pop_front();

        //去平均分
        int sum = 0;
        for (auto it1 : d)
        {
            sum += it1;    //累加每个评委的分数
        }
        int avg = sum / d.size();

        //将平均分，赋值给选手身上
        it.m_score = avg;
    }
}

void showscore(vector<Person>& v)
{
    for (auto& it : v)
    {
        cout << "姓名：" << it.m_name << " 平均分：" << it.m_score << endl;
    }
}

int  main()
{
    //1、创建5名选手
    vector<Person> v;
    creatperson(v);

    // //调试
    // for(auto it:v)
    // {
    //     cout<<"姓名："<<it.m_name<<"      分数："<<it.m_score<<endl;
    // }
    //2、给5名选手打分
    setscore(v);
    //3、显示最后得分
    showscore(v);
}